package vip.ola.pay.service.impl;

import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;
import vip.ola.core.common.util.MyLog;
import vip.ola.core.entity.PayOrder;
import vip.ola.core.entity.TransOrder;
import vip.ola.core.service.IPayNotifyService;
import vip.ola.pay.mq.BaseNotify4MchPay;
import vip.ola.pay.mq.BaseNotify4MchTrans;
import vip.ola.pay.service.RpcCommonService;

/**
 * @author: dingzhiwei
 * @date: 2018/5/29
 * @description:
 */
@Service(interfaceName = "vip.ola.core.service.IPayNotifyService", version = "1.0.0", retries = -1)
public class PayNotifyServiceImpl implements IPayNotifyService {

    private static final MyLog _log = MyLog.getLog(PayNotifyServiceImpl.class);

    @Autowired
    private RpcCommonService rpcCommonService;

	@Autowired
	public BaseNotify4MchPay baseNotify4MchPay;

	@Autowired
	public BaseNotify4MchTrans baseNotify4MchTrans;
	/**
	 * 发送支付订单通知
	 * @param payOrderId
	 */
	public void executePayNotify(String payOrderId) {
		_log.info(">>>>>> 调取rpc补发支付通知,payOrderId：{}", payOrderId);
		PayOrder payOrder = rpcCommonService.rpcPayOrderService.findByPayOrderId(payOrderId);
		baseNotify4MchPay.doNotify(payOrder, true);
		_log.info(">>>>>> 调取rpc补发支付通知完成  <<<<<<");
	}

	@Override
	public void executeTransNotify(String transOrderId) {
		_log.info(">>>>>> 调取rpc补发转账通知,payOrderId：{}", transOrderId);
		TransOrder transOrder = rpcCommonService.rpcTransOrderService.findByTransOrderId(transOrderId);
		baseNotify4MchTrans.doNotify(transOrder, true);
		_log.info(">>>>>> 调取rpc补发转账通知完成  <<<<<<");
	}


}
